from pymongo import MongoClient
import json
from config import AI_CONFIG

db_config = AI_CONFIG['mongodb']

client = MongoClient(db_config['host'])
db = client[db_config["mydb"]]
collection = db[db_config["contents"]]


def save(content, t="one"):
    if t == "one":
        collection.insert_one(content)
    else:
        if isinstance(content, list):
            collection.insert_many(content)
            return True
        else:
            return False
